package com.ayh.campusfun.common;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.PropertyPreFilter;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;

import java.util.ArrayList;
import java.util.List;

public class MulPropertyPreFilter implements PropertyPreFilter {

	private List<SimplePropertyPreFilter> filterList = new ArrayList<SimplePropertyPreFilter>();
	
	public void setFilterList(List<SimplePropertyPreFilter> filterList) {
		this.filterList = filterList;
	}
	public void addFilterList(SimplePropertyPreFilter filter) {
		this.filterList.add(filter);
	}

	@Override
	public boolean apply(JSONSerializer serializer, Object object, String name) {
		for(SimplePropertyPreFilter filter : filterList) {
			if(!filter.apply(serializer, object, name)) {
				return false;
			}
		}
		return true;
	}

}
